package com.gitee.qdbp.general.system.web.controller.personnel;

import com.gitee.qdbp.base.system.model.IAccountType;
import com.gitee.qdbp.general.system.api.personnel.model.AccountBean;

public class ValidatedAccount extends AccountBean {

    /** 版本序列号 **/
    private static final long serialVersionUID = 1L;

    /** 账户编号 **/
    private String id;

    /** 账户编号 **/
    public String getId() {
        return id;
    }

    /** 账户编号 **/
    public void setId(String id) {
        this.id = id;
    }

    public String toString() {
        String factory = getFactory();
        IAccountType type = getType();
        String account = getAccount();
        StringBuilder buffer = new StringBuilder();
        if (id != null) {
            if (buffer.length() > 0) {
                buffer.append(",");
            }
            buffer.append("id:").append(id);
        }
        if (factory != null) {
            if (buffer.length() > 0) {
                buffer.append(",");
            }
            buffer.append("factory:").append(factory);
        }
        if (type != null) {
            if (buffer.length() > 0) {
                buffer.append(",");
            }
            buffer.append("type:").append(type);
        }
        if (account != null) {
            if (buffer.length() > 0) {
                buffer.append(",");
            }
            buffer.append("phone:").append(account);
        }
        return "{" + buffer.toString() + "}";
    }

    public static ValidatedAccount of(String id, AccountBean bean) {
        ValidatedAccount result = new ValidatedAccount();
        result.setId(id);
        result.setFactory(bean.getFactory());
        result.setType(bean.getType());
        result.setAccount(bean.getAccount());
        return result;
    }
}
